package service.impl;

import dao.*;
import dao.impl.UserDaoImpl;
import pojo.User;
import service.UserService;

import java.util.List;

public class UserServiceImpl implements UserService {

    private UserDao userDao=new UserDaoImpl();

    @Override
    public void registerUser(User user) {
        userDao.saveUser(user);
    }

    @Override
    public User login(User user) {
        return userDao.queryUserByUsernameAndPassword(user.getUsername(),user.getPassword());
    }

    @Override
    public boolean existsUsername(String username) {
        if(userDao.queryUserByUsernaem(username)== null)
        {
            return false;
        }
        return true;
    }

    @Override
    public List<User> searchUsername(String usernames) {
        return userDao.quertByUsersinglename(usernames);
    }
}
